package com.well.register.event;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

@Component
public class FindEventOfBean implements BeanPostProcessor {

    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        if(bean instanceof AppEvent){
            AppEvent event = (AppEvent) bean;
            EventContext.setEvent(event.eventType(),event);
        }
        return bean;
    }
}
